/**
 * == ajax 请求，Http 模块 ==
 * */
function Http() {

}
Http.prototype = {
    ajax: function (options) {
        if(glob.isDebug) {
            $.get(options.url + '.json', options.success);
        }else {
            $.ajax(utils.deepMerge({
                dataType: 'json',
                cache: false,
                xhrFields: { withCredentials: true },
                headers: {
                    'Authorization': glob.token,
                    'APP': glob.app,
                    'ACTIVITY': glob.activity,
                    'VERSIONCODE': glob.version,
                    'PLAT': glob.platform,
                    'CYSCID': glob.cyscid,
                    'CYSTID': glob.cystid
                }
            }, options));
        }
    },
    common: function(type, url, variate, fun) {
        var data = {};
        if(typeof variate === 'function') {
            fun = variate;
        }else {
            data = variate;
        }
        this.ajax({
            type: type,
            url: glob.originOnly + url,
            data: data,
            success: fun
        });
    },
    get: function(variate1, variate2, fun) {
        if(typeof variate1 === 'string') {
            this.common('GET',  variate1, variate2, fun);
        }else
            this.ajax(utils.deepMerge(variate1, { type: 'GET' }))
    },
    post: function(variate1, variate2, fun) {
        if(typeof variate1 === 'string') {
            this.common('POST', variate1, variate2, fun);
        }else
            this.ajax(utils.deepMerge(variate1, { type: 'POST' }))
    }
};
var http = new Http();